package br.com.massai.model.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.envers.Audited;

@Entity
@Audited
@Table(name = "PRODUCTION_GROUP")
@NamedQueries({
	@NamedQuery(name = "ProductionGroup.find", query = "SELECT p FROM ProductionGroup p"),
	@NamedQuery(name = "ProductionGroup.duplicate", query = "SELECT COUNT(p) FROM ProductionGroup p WHERE LOWER(p.nameGroup) = LOWER(:nameGroup) AND p.status = :status")
})
public class ProductionGroup extends GenericEntity {

	private static final long serialVersionUID = -3540113624038907120L;

	@Id
	@SequenceGenerator(name = "seqProductionGroup", sequenceName = "seq_production_group", allocationSize = 1)
	@GeneratedValue(generator = "seqProductionGroup", strategy = GenerationType.SEQUENCE)
	private Long id;

	@Column(name = "NAME_GROUP", length = 255, nullable = false)
	private String nameGroup;

	@Column(name = "STATUS", columnDefinition = "BOOLEAN DEFAULT true")
	private boolean status;
	
	//TODO add relationship with SPREADSHEET_ITEM
	
	//TODO add relationship with DEPARTMENT

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNameGroup() {
		return nameGroup;
	}

	public void setNameGroup(String nameGroup) {
		this.nameGroup = nameGroup;
	}

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}
}